/*==============================================================*/
/* Table: SYS_CONFIG_INFO                                       */
/*==============================================================*/
CREATE TABLE SYS_CONFIG_INFO
(
   ID                   VARCHAR2(32)         NOT NULL,
   CONFIG_NAME          VARCHAR2(100)        NOT NULL,
   CONFIG_KEY           VARCHAR2(100)        NOT NULL,
   CONFIG_VALUE         VARCHAR2(100)        NOT NULL,
   CONFIG_TYPE          NUMBER(5)            DEFAULT 0,
   CREATE_BY            VARCHAR2(64)         NOT NULL,
   CREATE_TIME          DATE DEFAULT CURRENT_DATE NOT NULL,
   UPDATE_BY            VARCHAR2(64)         NOT NULL,
   UPDATE_TIME          DATE DEFAULT CURRENT_DATE NOT NULL,
   REMARK               VARCHAR2(500),
   CONSTRAINT PK_SYS_CONFIG_INFO PRIMARY KEY (ID)
);

COMMENT ON TABLE SYS_CONFIG_INFO IS '参数配置表';
COMMENT ON COLUMN SYS_CONFIG_INFO.CONFIG_NAME IS '配置名称';
COMMENT ON COLUMN SYS_CONFIG_INFO.CONFIG_KEY IS '配置键';
COMMENT ON COLUMN SYS_CONFIG_INFO.CONFIG_VALUE IS '配置键值';
COMMENT ON COLUMN SYS_CONFIG_INFO.CONFIG_TYPE IS '配置类型';
COMMENT ON COLUMN SYS_CONFIG_INFO.CREATE_BY IS '创建者';
COMMENT ON COLUMN SYS_CONFIG_INFO.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN SYS_CONFIG_INFO.UPDATE_BY IS '更新者';
COMMENT ON COLUMN SYS_CONFIG_INFO.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN SYS_CONFIG_INFO.REMARK IS '备注';

@DELIMITER %%% ;
/** FUNCTION,如果用dbvisualizer,   需要添加下面所有的注释掉的行 （一共3行）                                    */
/**   */
 
CREATE OR REPLACE FUNCTION "GENTABID"
(TABNAME IN VARCHAR2)
RETURN VARCHAR2
AS
PRAGMA AUTONOMOUS_TRANSACTION;

ID VARCHAR2(30);
TMP VARCHAR2(14);

T_SYS_CODE VARCHAR2(20);
T_TABLE_CODE VARCHAR2(20);
T_SEQUENCE NUMBER := 0;

BEGIN
TMP := SUBSTR(TABNAME,0,26);
EXECUTE IMMEDIATE 'SELECT SEQ_' || TMP || '.NEXTVAL FROM DUAL' INTO T_SEQUENCE;
SELECT TO_CHAR( SYSDATE, 'YYYYMMDDHH24MISS') INTO TMP FROM DUAL;
ID := CONCAT(CONCAT(TMP, T_TABLE_CODE), LPAD(T_SEQUENCE,12,'0'));

COMMIT;
RETURN ID;
END;

@DELIMITER ; %%%
